﻿
@{
    ViewBag.Title = "Index";
    Layout = "~/Views/Shared/_LayoutFront.cshtml";
}
@model List<Blog190311.Models.UIData>
<div class="picbox">
    @for (var i = 0; i < this.Model.Count; i = i + 2)
    {
        <ul>
            <li data-scroll-reveal="enter bottom over 1s" style="height:400px">
                <a href="/Share/Detail/ @this.Model[i].Id">
                    <i><img src="~/@this.Model[i].PicUrl" style="height:280px"></i>
                    <div class="picinfo">
                        <h3>@this.Model[i].Title</h3>
                        @if (this.Model[i].Cont.Length > 8)
                        {
                            <span>@this.Model[i].Cont.ToString().Substring(0, 8)...</span>
                        }
                        else
                        {
                            <span>@this.Model[i].Cont</span>
                        }
                    </div>
                </a>
            </li>
            <li data-scroll-reveal="enter bottom over 1s" style="height:400px">
                <a href="/Share/Detail/ @this.Model[i + 1].Id">
                    <i><img src="~/@this.Model[i+1].PicUrl" style="height:280px"></i>
                    <div class="picinfo">
                        <h3>@this.Model[i + 1].Title</h3>
                        @if (this.Model[i + 1].Cont.Length > 8)
                        {
                            <span>@this.Model[i + 1].Cont.ToString().Substring(0, 8)...</span>
                        }
                        else
                        {
                            <span>@this.Model[i + 1].Cont</span>
                        }
                    </div>
                </a>
            </li>
        </ul>
    }
</div>
<div id="pagelist"></div>

<script>
    layui.use('laypage', function () {
        var laypage = layui.laypage;
        //执行一个laypage实例
        laypage.render({
            elem: 'pagelist'
            , count:@ViewBag.total//数据总数，从服务端得到
            , limit: @ViewBag.limit
            , curr: @ViewBag.page
            , jump: function (obj, first) {
                //ob包含了当前分页的所有参数，比如:
                console.log(obj.curr); //得到当前页，以便向服务端请求对应页的数据。
                console.log(obj.limit); //得到每页显示的条数
                //首次不执行
                if (!first) {
                    //do something
                    var con = $('#keyboard').val();//获取到查询内容
                    var href = '/Share/Index';
                    href += '?page=' + obj.curr;
                    href += '&limit='+ obj.limit;
                    console.log(href)
                    location.href = href;//页面跳转到指定页面
                }
            }
        });
    });
</script>